library(ggplot2)
## Warning: package 'ggplot2' was built under R version 4.1.2
library(plotly)
## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout
library(scales)
p <- ggplot(txhousing, aes(date, median)) + 
  geom_line(aes(
    group = city, 
    text = paste("median:", number(median))
  ))
## Warning: Ignoring unknown aesthetics: text
ggplotly(p, tooltip = c("text", "x", "city"))